package com.wqc;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

public class Producer {

    public static void main(String[] args) throws InterruptedException {
        ApplicationContext context = new ClassPathXmlApplicationContext("rabbit/amqp-producer.xml");
        AmqpTemplate template = (AmqpTemplate) context.getBean("rabbitTemplate");
        for (int i = 0; i < 1000; i++) {
            System.out.println("Sending message #" + i);
            Spittle spittle = new Spittle((long) i, "Hello world (" + i + ")", new Date());
            template.convertAndSend(spittle);
            //Thread.sleep(3000);
        }
        System.out.println("Done!");
    }

}
